table of contents
LWRES_GETIPNODE(3) | BIND9 | LWRES_GETIPNODE(3) |
NAME¶
lwres_getipnodebyname, lwres_getipnodebyaddr, lwres_freehostent - lightweight resolver nodename / address translation API
SYNOPSIS¶
#include <lwres/netdb.h>
struct hostent * lwres_getipnodebyname(const char *name, int af, int flags, int *error_num);
struct hostent * lwres_getipnodebyaddr(const void *src, size_t len, int af, int *error_num);
void lwres_freehostent(struct hostent *he);
DESCRIPTION¶
These functions perform thread safe, protocol independent nodename-to-address and address-to-nodename translation as defined in RFC2553.
They use a struct hostent which is defined in namedb.h:
struct hostent {
char *h_name; /* official name of host */
char **h_aliases; /* alias list */
int h_addrtype; /* host address type */
int h_length; /* length of address */
char **h_addr_list; /* list of addresses from name server */ }; #define h_addr h_addr_list[0] /* address, for backward compatibility */
The members of this structure are:
h_name
h_aliases
h_addrtype
h_length
h_addr_list
lwres_getipnodebyname() looks up addresses of protocol family af for the hostname name. The flags parameter contains ORed flag bits to specify the types of addresses that are searched for, and the types of addresses that are returned. The flag bits are:
AI_V4MAPPED
AI_ALL
AI_ADDRCONFIG
AI_DEFAULT
lwres_getipnodebyaddr() performs a reverse lookup of address src which is len bytes long. af denotes the protocol family, typically PF_INET or PF_INET6.
lwres_freehostent() releases all the memory associated with the struct hostent pointer he. Any memory allocated for the h_name, h_addr_list and h_aliases is freed, as is the memory for the hostent structure itself.
RETURN VALUES¶
If an error occurs, lwres_getipnodebyname() and lwres_getipnodebyaddr() set *error_num to an appropriate error code and the function returns a NULL pointer. The error codes and their meanings are defined in <lwres/netdb.h>:
HOST_NOT_FOUND
NO_ADDRESS
TRY_AGAIN
NO_RECOVERY
lwres_hstrerror(3) translates these error codes to suitable error messages.
SEE ALSO¶
RFC2553(), lwres(3), lwres_gethostent(3), lwres_getaddrinfo(3), lwres_getnameinfo(3), lwres_hstrerror(3).
COPYRIGHT¶
Copyright © 2004, 2005, 2007 Internet Systems Consortium,
Inc. ("ISC")
Copyright © 2000, 2001, 2003 Internet Software Consortium.
June 30, 2000 | BIND9 |